<template>
  <div class="wrapper">
    <web-view v-if="url" :src="url"></web-view>
    <!-- <div class="cant" v-else v-html="html"></div> -->
    <wxParse v-if="html" :imageProp="{mode:'widthFix'}" :content="html" />
  </div>
</template>

<script>

import wxParse from 'mpvue-wxparse'
export default {
  components: {
    wxParse
  },
  data() {
    return {
      url: "",
      html: "",
    };
  },
  onLoad() {
    this.url = "";
    this.html = "";
    this.url = this.$root.$mp.query.url;
    if (this.$root.$mp.query.id) [this.fetchData(this.$root.$mp.query.id)];
  },
  methods: {
    /**
     * 获取banner 轮播图的内容
     */
    fetchData(id) {
      this.$http
        .post({
          url: "/mobile/api/adinfo",
          data: { id: id }
        })
        .then(res => {
          if (res.code == "RX0000") {
            this.html = res.data.ad_desc;
            wx.setNavigationBarTitle({
              title: res.data.ad_title
            });
          }
        });
    }
  }
};
</script>
<style>
.wrapper {
  padding: 10px;
  line-height: 1.5;
}
/* .wrapper image {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
} */
.cant {
  margin-bottom: 36px;
}
.wrapper .img {
  max-width: 100% !important;
}
</style>
